package com.client;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class Client {

	public static void main(String[] args) {
		try {
			String json = "{\"class_\":\"com.index.InvertedIndex\",\"method_\":\"run\",\"param\":'/metric/00004/1/20151023/1445571478277'}";
			// 向本机的8888端口发出客户请求
			Socket socket = new Socket("192.168.10.153", 8888);
			System.out.println("Established a connection...");
			// 由Socket对象得到输出流,并构造PrintWriter对象
			PrintWriter out = new PrintWriter(socket.getOutputStream());
			out.println(json);
			// 刷新输出流,使Server马上收到该字符串
			out.flush();
			out.close(); // 关闭Socket输出流
			socket.close(); // 关闭Socket
		} catch (Exception e) {
			System.out.println("Error. " + e);
		}
	}
}
